<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>企业注册</title>
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css"" rel="stylesheet">
<link href="./assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="./css/register.css">
<link rel='stylesheet' href="./css/animate.min.css">
<link rel="stylesheet" href="./css/notification.css">
<style>
input[type=file]:focus, input[type=checkbox]:focus, input[type=radio]:focus,
	input[type=button]:focus {
	outline: none;
}
.btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus {
    outline: none;}
.input-group{
	width: 500px;
	margin: auto;
	padding-top: 10px;
}
</style>
</head>

<body>
	<div class="navbar panel navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand" href="./index.html"> <img src="./assets/logo.png"
					height="45px" class="brand-logo" alt="logo" /> 冷链<strong>溯源系统</strong>
				</a>
			</div>
			<div class="pull-right">
				<a class="main-menu--item" href="./index.html"><i
					class="fa fa-home"></i> 主页</a> <a class="main-menu--item"
					href="./demo.html"><i class="fa fa-cube"></i> 案例</a> <a
					class="main-menu--item" href="./register.html"><i
					class="fa fa-handshake-o"></i> 加盟</a> <a class="main-menu--item"
					href="./about.html"><i class="fa fa-info"></i> 关于</a>
			</div>
		</div>
	</div>
	<div id="mainbody">
		<div class="container">
			<div id="regist">
				<form class="form-horizontal">
					<fieldset>
						<!-- Form Name -->
						<legend>企 业 加 盟</legend>
						<p>
							温馨提示：（<span class="need">*</span> 为必填项）注：企业完成注册后需进行主体身份验证才能使用本系统!
						</p>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon1">*企业</span>
							<input type="text" id="userEnterprise" class="form-control" name="userEnterprise" placeholder="请输入企业全称" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon2">*姓名</span>
							<input type="text" id="managerName" name="managerName" class="form-control" placeholder="请输入真实姓名" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon3">*用户名</span>
							<input type="text" id="userName" name="userName" class="form-control" placeholder="请输入用户名" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon4">*邮箱</span>
							<input type="email" id="userEmail" name="userEmail" class="form-control" placeholder="请输入邮箱" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon5">*手机</span>
							<input type="tel" id="userPhone" name="userPhone" class="form-control" placeholder="请输入手机" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon6">*密码</span>
							<input type="password" id="passwordinput-1" name="passwordinput-1" class="form-control" placeholder="请输入密码" aria-describedby="sizing-addon1">
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon7">*确认密码</span>
							<input type="password" id="passwordinput-2" name="passwordinput-2" class="form-control" placeholder="请输入确认密码" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div class="input-group">
							<span class="input-group-addon" id="sizing-addon8">*验证码</span>
							<input type="text" id="code_input" name="code_input" class="form-control" placeholder="请输入验证码" aria-describedby="sizing-addon1">
							<p class="help-block"></p>
						</div>
						<div id="v_container" style="padding-top: 10px"></div>

						<!-- Button (Double) -->
						<div class="control-group">
							<!--<label class="control-label" for="doublebutton-0">Double Button</label>-->
							<div class="controls">
								<button id="registBtn" name="registBtn" class="btn btn-success">
									注 册</button>
							</div>
						</div>

					</fieldset>
				</form>
				<p>
					联系管理员：<i class="fa fa-phone">***********&nbsp;&nbsp;&nbsp;&nbsp;</i>
					<i class="fa fa-send">**********@163.com</i>
				</p>
			</div>
		</div>
	</div>
	<script src="./plugs/jquery-3.1.1.min.js"></script>
	<script src="./assets/bootstrap/js/bootstrap.min.js"></script>
	<script src="./js/gVerify.js"></script>
	<script src="./js/notification.js"></script>

	<script>
		$(function() {
			$("#mainbody .container").css('min-height', $(window).height());
			$("#regist").css('min-height', $(window).height());

			var verifyCode = new GVerify("v_container");
			var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
			var mobile = /^((13[0-9]{1})|159|153)+\d{8}$/;
			$('#registBtn')
					.bind(
							'click',
							function(event) {
								event.preventDefault();
								var res = verifyCode.validate($('#code_input')
										.val());
								if ($("#userEnterprise").val().length == 0
										|| $("#managerName").val().length == 0
										|| $("#userName").val().length == 0
										|| $("#userEmail").val().length == 0
										|| $("#userPhone").val().length == 0
										|| $('#code_input').val().length == 0
										|| $("#passwordinput-1").val().length == 0
										|| $("#passwordinput-2").val().length == 0) {
									Notification.create("Notification",
											"请填写所有必填项！;( ！",
											"./assets/cat.jpg", "flipInX", 2);
								} else {
									if (res) {
										if ($("#passwordinput-1").val() !== $(
												"#passwordinput-2").val()) {
											Notification.create("Notification",
													"两次填写的密码不同，请重新确认！;( ！",
													"./assets/cat.jpg",
													"flipInX", 2);
										} else if (!myreg.test($("#userEmail")
												.val())) {
											Notification.create("Notification",
													"请输入正确的邮箱！;( ！",
													"./assets/cat.jpg",
													"flipInX", 2);
										} else {
											$.ajax({
														type : 'POST',
														url : "system/addRegisterTmpInfo.do",
														data : {
															"businessName" : $(
																	"#userEnterprise")
																	.val(),
															"managerName" : $(
																	"#managerName")
																	.val(),

															"managerNum" : $(
																	"#userName")
																	.val(),
															"managerEmail" : $(
																	"#userEmail")
																	.val(),
															"managerPhone" : $(
																	"#userPhone")
																	.val(),
															"managerPwd" : $(
																	"#passwordinput-1")
																	.val()
														},
														success : function(data) {
															if (data == "exist") {
																Notification
																	.create(
																			"Notification",
																			"用户名已存在,请重新输入注册用户名 ！",
																			"./assets/cat.jpg",
																			"flipInX",
																			2);
															}
															if (data == "true") {
																Notification
																	.create(
																			"Notification",
																			"注册提交成功，等待认证！有问题可致电管理员！;) ！",
																			"./assets/cat.jpg",
																			"flipInX",
																			2);
																$("#userEnterprise")
																	.val("");
																$("#managerName")
																	.val("");
																$("#userName")
																	.val("");
																$("#userEmail")
																	.val("");
																$("#userPhone")
																	.val("");
																$('#code_input')
																	.val("");
																$("#passwordinput-1")
																	.val("");
																$("#passwordinput-2")
																	.val("");
																$("#code_input")
																	.val("");
															} else {
																Notification
																		.create(
																				"Notification",
																				"注册失败，请稍后重试！;( ！",
																				"./assets/cat.jpg",
																				"flipInX",
																				2);
															}

														},
														error : function(status) {
															Notification
																	.create(
																			"Notification",
																			"不好意思，发生未知错误！;(！",
																			"./assets/cat.jpg",
																			"flipInX",
																			2);
														}
													});
										}
									} else {
										Notification.create("Notification",
												"验证码错误，请重新填写！！;( ！",
												"./assets/cat.jpg", "flipInX",
												2);
									}
								}
							});
		});
	</script>

</body>

</html>